package day08;

import java.util.Scanner;

/**
 * @author Xiao
 * @date 2021/7/9
 */
public class countString {
    /**
     *      统计字符次数
     */
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        System.out.println("请输入一个字符串：");
        String s = sc.nextLine();
        System.out.println("---------------");
        int count1 = 0;
        int count2 = 0;
        int count3 = 0;
        int count4 = 0;
        for (int i = 0; i < s.length(); i++) {
            char ch = s.charAt(i);
            if (ch >= 'A' && ch <= 'Z') {
                count1 ++;
            } else if (ch >= 'a' && ch <= 'z') {
                count2 ++;
            } else if (ch >= '0' && ch <= '9') {
                count3 ++;
            } else {
                count4 ++;
            }
        }
/*
        char[] ch = s.toCharArray();
        for (int i = 0; i < ch.length; i++) {
            if (ch[i] >= 'A' && ch[i] <= 'Z') {
                count1++;
            }   //  ……省略
        }
*/
        System.out.println("'A' - 'Z':\t" + count1);
        System.out.println("'a' - 'z':\t" + count2);
        System.out.println("'0' - '9':\t" + count3);
        System.out.println("others:\t" + count4);
    }
}
